/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Model.Entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ubuntu
 */
@Entity
@Table(catalog = "copa", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Ingressos.findAll", query = "SELECT i FROM Ingressos i"),
    @NamedQuery(name = "Ingressos.findById", query = "SELECT i FROM Ingressos i WHERE i.id = :id"),
    @NamedQuery(name = "Ingressos.findByCadeira", query = "SELECT i FROM Ingressos i WHERE i.cadeira = :cadeira"),
    @NamedQuery(name = "Ingressos.findByPreco", query = "SELECT i FROM Ingressos i WHERE i.preco = :preco")})
public class Ingressos implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 5)
    private String cadeira;
    @Basic(optional = false)
    @NotNull
    private float preco;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ingressoId")
    private Collection<Compra> compraCollection;
    @JoinColumn(name = "jogo_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Jogos jogoId;

    public Ingressos() {
    }

    public Ingressos(Integer id) {
        this.id = id;
    }

    public Ingressos(Integer id, String cadeira, float preco) {
        this.id = id;
        this.cadeira = cadeira;
        this.preco = preco;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCadeira() {
        return cadeira;
    }

    public void setCadeira(String cadeira) {
        this.cadeira = cadeira;
    }

    public float getPreco() {
        return preco;
    }

    public void setPreco(float preco) {
        this.preco = preco;
    }

    @XmlTransient
    public Collection<Compra> getCompraCollection() {
        return compraCollection;
    }

    public void setCompraCollection(Collection<Compra> compraCollection) {
        this.compraCollection = compraCollection;
    }

    public Jogos getJogoId() {
        return jogoId;
    }

    public void setJogoId(Jogos jogoId) {
        this.jogoId = jogoId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ingressos)) {
            return false;
        }
        Ingressos other = (Ingressos) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.Ingressos[ id=" + id + " ]";
    }
    
}
